package com.dudu.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dudu.domain.Building;
import com.dudu.domain.Room;
import com.dudu.service.BuildingService;
import com.dudu.service.RoomService;
import com.dudu.service.RoomTypeService;

/** 主页
 * Created by tengj on 2017/4/10.
 */


@Controller
public class IndexController {
    @Autowired
    private RoomService roomService;
	@Autowired
	RoomTypeService roomTypeService;
	@Autowired
	BuildingService buildingService;

//    @RequestMapping("/index")
//    public String index(){
//        return "index";
//    }
//    @RequestMapping("/")
//    public String index2(){
//        return "index";
//    }
    
    @RequestMapping(value = "/list", produces = "application/json; charset=utf-8")
    @ResponseBody
    public Map<String, Object> roomList(){
    	List<Building> buildingList=buildingService.getAllBuilding();
    	List<Room> roomList=roomService.getAllRoom();
    	
        Map<String, Object> map=new HashMap<>();
        map.put("roomlist", roomList); 
        map.put("building", buildingList);
        return map ;
    }
    
}
